<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Tmsg extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('tmsg',array('engine'=>'INnoDB'));
        $table->addColumn('template_id', 'string',array('limit' => 50,'comment'=>'模板ID'))
            ->addColumn('title', 'string',array('limit' => 50,'comment'=>'模板标题'))
            ->addColumn('primary_industry', 'string',array('limit' => 50,'comment'=>'模板所属行业的一级行业'))
            ->addColumn('deputy_industry', 'string',array('limit' => 50,'default'=>'','comment'=>'模板所属行业的二级行业'))
            ->addColumn('content', 'string',array('limit' => 1000,'comment'=>'模板内容'))
            ->addColumn('example', 'string',array('limit' => 1000,'default'=>'','comment'=>'模板示例'))
            ->addColumn('add_time', 'datetime',array('default'=>'CURRENT_TIMESTAMP','comment'=>'添加时间'))
            ->addColumn('update_time', 'datetime',array('default'=>'CURRENT_TIMESTAMP','comment'=>'更新时间'))
            ->addColumn('wechat_id', 'string',array('limit' => 30,'comment'=>'微信id'))
            ->addIndex(array('template_id'), array('unique' => true))
            ->create();
    }
}
